import { uniqueId } from "lodash";

/**
 * @description 给菜单数据补充上 path 字段
 * @description https://github.com/d2-projects/d2-admin/issues/209
 * @param {Array} menu 原始的菜单数据
 */
function supplementPath(menu) {
  return menu.map(e => ({
    ...e,
    path: e.path || uniqueId("d2-menu-empty-"),
    ...(e.children
      ? {
          children: supplementPath(e.children)
        }
      : {})
  }));
}

export const menuHeader = supplementPath([]);

export const menuAside = supplementPath([
  { path: "/index", title: "首页", icon: "home" },
  {
    title: "企业管理",
    icon: "cube",
    children: [
      { path: "enterprise", title: "企业列表", icon: "cube" },
      { path: "recruitInfo", title: "招募列表", icon: "cube" }
    ]
  },
  {
    title: "用户管理",
    icon: "user",
    children: [
      { path: "user", title: "用户列表", icon: "user" },
      { path: "feedback", title: "用户反馈", icon: "user" }
    ]
  },
  {
    title: "系统管理",
    icon: "windows",
    children: [
      { path: "addAdmin", title: "添加管理员", icon: "send" },
      { path: "userInfo", title: "个人信息", icon: "user" }
    ]
  },
  {
    title: "数据分析",
    icon: "windows",
    children: [{ path: "dataAnalysis", title: "可视化分析", icon: "windows" }]
  }
]);
